﻿using PBDesk.Utilities;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;

namespace PBDesk.Utilities.Tests
{
    
    
    /// <summary>
    ///This is a test class for StringExtensionsTest and is intended
    ///to contain all StringExtensionsTest Unit Tests
    ///</summary>
    [TestClass()]
    public class StringExtensionsTest
    {
        enum Colors1
        {
            Red = 1,
            Yellow = 2,
            Blue = 3
        }


        private TestContext testContextInstance;

        /// <summary>
        ///Gets or sets the test context which provides
        ///information about and functionality for the current test run.
        ///</summary>
        public TestContext TestContext
        {
            get
            {
                return testContextInstance;
            }
            set
            {
                testContextInstance = value;
            }
        }

        #region Additional test attributes
        // 
        //You can use the following additional attributes as you write your tests:
        //
        //Use ClassInitialize to run code before running the first test in the class
        //[ClassInitialize()]
        //public static void MyClassInitialize(TestContext testContext)
        //{
        //}
        //
        //Use ClassCleanup to run code after all tests in a class have run
        //[ClassCleanup()]
        //public static void MyClassCleanup()
        //{
        //}
        //
        //Use TestInitialize to run code before running each test
        //[TestInitialize()]
        //public void MyTestInitialize()
        //{
        //}
        //
        //Use TestCleanup to run code after each test has run
        //[TestCleanup()]
        //public void MyTestCleanup()
        //{
        //}
        //
        #endregion


        /// <summary>
        ///A test for As
        ///</summary>
        public void AsTestHelper<T>()
        {
            string strValue = string.Empty; // TODO: Initialize to an appropriate value
            T expected = default(T); // TODO: Initialize to an appropriate value
            T actual;
            bool b;
            //Case#01
            strValue = "true";
            b = strValue.As<bool>();
            Assert.AreEqual(b, true);

            //Case#02
            strValue = "false";
            b = strValue.As<bool>();
            Assert.AreEqual(b, false);

            //Case#03
            strValue = "False";
            b = strValue.As<bool>();
            Assert.AreEqual(b, false);

            //Case#04
            strValue = "True";
            b = strValue.As<bool>();
            Assert.AreEqual(b, true);

            
            //Case#05
            strValue = "Red";
            Colors1 c = strValue.As<Colors1>();
            Assert.AreEqual(c, Colors1.Red);

            //Case#03
            strValue = "0";
            b = strValue.As<bool>();
            Assert.AreEqual(b, false);
            
            //Assert.AreEqual(expected, actual);
            Assert.Inconclusive("Verify the correctness of this test method.");
        }

        [TestMethod()]
        public void AsTest()
        {
            AsTestHelper<GenericParameterHelper>();
        }

        /// <summary>
        ///A test for As
        ///</summary>
        public void AsTest1Helper<T>()
        {
            string strValue = string.Empty; // TODO: Initialize to an appropriate value
            T defaultValue = default(T); // TODO: Initialize to an appropriate value
            T expected = default(T); // TODO: Initialize to an appropriate value
            T actual;
            actual = StringExtensions.As<T>(strValue, defaultValue);
            Assert.AreEqual(expected, actual);
            Assert.Inconclusive("Verify the correctness of this test method.");
        }

        [TestMethod()]
        public void AsTest1()
        {
            AsTest1Helper<GenericParameterHelper>();
        }

        /// <summary>
        ///A test for IsNotNull
        ///</summary>
        [TestMethod()]
        public void IsNotNullTest()
        {
            string inputString = string.Empty; // TODO: Initialize to an appropriate value
            bool expected = false; // TODO: Initialize to an appropriate value
            bool actual;
            actual = StringExtensions.IsNotNull(inputString);
            Assert.AreEqual(expected, actual);
            Assert.Inconclusive("Verify the correctness of this test method.");
        }

        /// <summary>
        ///A test for IsNotNullAndNotEmpty
        ///</summary>
        [TestMethod()]
        public void IsNotNullAndNotEmptyTest()
        {
            string inputString = string.Empty; // TODO: Initialize to an appropriate value
            bool expected = false; // TODO: Initialize to an appropriate value
            bool actual;
            actual = StringExtensions.IsNotNullAndNotEmpty(inputString);
            Assert.AreEqual(expected, actual);
            Assert.Inconclusive("Verify the correctness of this test method.");
        }

        /// <summary>
        ///A test for IsNull
        ///</summary>
        [TestMethod()]
        public void IsNullTest()
        {
            string inputString = string.Empty; // TODO: Initialize to an appropriate value
            bool expected = false; // TODO: Initialize to an appropriate value
            bool actual;
            actual = StringExtensions.IsNull(inputString);
            Assert.AreEqual(expected, actual);
            Assert.Inconclusive("Verify the correctness of this test method.");
        }

        /// <summary>
        ///A test for IsNullOrEmpty
        ///</summary>
        [TestMethod()]
        public void IsNullOrEmptyTest()
        {
            string inputstr = string.Empty; // TODO: Initialize to an appropriate value
            bool expected = false; // TODO: Initialize to an appropriate value
            bool actual;
            actual = StringExtensions.IsNullOrEmpty(inputstr);
            Assert.AreEqual(expected, actual);
            Assert.Inconclusive("Verify the correctness of this test method.");
        }

        /// <summary>
        ///A test for IsRegexMatch
        ///</summary>
        [TestMethod()]
        public void IsRegexMatchTest()
        {
            string original = string.Empty; // TODO: Initialize to an appropriate value
            string regex = string.Empty; // TODO: Initialize to an appropriate value
            bool expected = false; // TODO: Initialize to an appropriate value
            bool actual;
            actual = StringExtensions.IsRegexMatch(original, regex);
            Assert.AreEqual(expected, actual);
            Assert.Inconclusive("Verify the correctness of this test method.");
        }

        /// <summary>
        ///A test for ToEnum
        ///</summary>
        public void ToEnumTestHelper<T>()
            where T : struct
        {
            string inString = string.Empty; // TODO: Initialize to an appropriate value
            T defaultValue = new T(); // TODO: Initialize to an appropriate value
            bool ignoreCase = false; // TODO: Initialize to an appropriate value
            bool throwException = false; // TODO: Initialize to an appropriate value
            T expected = new T(); // TODO: Initialize to an appropriate value
            T actual;
            actual = StringExtensions.ToEnum<T>(inString, defaultValue, ignoreCase, throwException);
            Assert.AreEqual(expected, actual);
            Assert.Inconclusive("Verify the correctness of this test method.");
        }

        [TestMethod()]
        public void ToEnumTest()
        {
            Assert.Inconclusive("No appropriate type parameter is found to satisfies the type constraint(s) of T. " +
                    "Please call ToEnumTestHelper<T>() with appropriate type parameters.");
        }

        /// <summary>
        ///A test for ToEnum
        ///</summary>
        public void ToEnumTest1Helper<T>()
            where T : struct
        {
            string inString = string.Empty; // TODO: Initialize to an appropriate value
            bool ignoreCase = false; // TODO: Initialize to an appropriate value
            bool throwException = false; // TODO: Initialize to an appropriate value
            T expected = new T(); // TODO: Initialize to an appropriate value
            T actual;
            actual = StringExtensions.ToEnum<T>(inString, ignoreCase, throwException);
            Assert.AreEqual(expected, actual);
            Assert.Inconclusive("Verify the correctness of this test method.");
        }

        [TestMethod()]
        public void ToEnumTest1()
        {
            Assert.Inconclusive("No appropriate type parameter is found to satisfies the type constraint(s) of T. " +
                    "Please call ToEnumTest1Helper<T>() with appropriate type parameters.");
        }
    }
}
